public class SmallestNumber {


  public static int smallestNumber(int n) {
    int bitLength = 32 - Integer.numberOfLeadingZeros(n);
    return (1 << bitLength) - 1;
  }

  public static void main(String[] args) {
    int n = 5;
    int ans = smallestNumber(n);
    System.out.println(ans);
  }
}

// 返回大于等于n的最小正整数，其仅包含置位位；